package com.hsjk.szwj.module.train.controller.app;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.framework.common.pojo.PageResult;
import com.hsjk.szwj.framework.security.core.annotations.PreAuthenticated;
import com.hsjk.szwj.module.train.controller.app.vo.checkoutorder.AppMyCheckoutOrderDetailReqVO;
import com.hsjk.szwj.module.train.controller.app.vo.checkoutorder.AppMyCheckoutOrderDetailRespVO;
import com.hsjk.szwj.module.train.controller.app.vo.checkoutorder.AppMyCheckoutOrderSummaryRespVO;
import com.hsjk.szwj.module.train.service.ICheckoutOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

/**
 * @author chenjiawei
 * @desc
 * @Date 2023/09/09 22:48
 **/
@Tag(name = "应用端 - 结算单相关接口")
@RestController
@RequestMapping("/train/checkout-order")
@Validated
public class AppCheckoutOrderController {
    @Resource
    private ICheckoutOrderService checkoutOrderService;

    @PostMapping("/page-my-performance-detail")
    @Operation(summary = "获取当前用户的推广数据明细")
    @PreAuthenticated
    public CommonResult<PageResult<AppMyCheckoutOrderDetailRespVO>> getMyPerformanceDetailPage(
            @RequestBody @Valid AppMyCheckoutOrderDetailReqVO reqVO) {
        return success(checkoutOrderService.getMyPerformanceDetailPage(reqVO));
    }

    @GetMapping("/get-my-summary")
    @Operation(summary = "获取当前用户结算单汇总数据")
    @PreAuthenticated
    public CommonResult<AppMyCheckoutOrderSummaryRespVO> getMyCheckoutOrderSummary() {
        return success(checkoutOrderService.getMyCheckoutOrderSummary());
    }
}
